package TestString;

import java.util.Arrays;

public class TestArray {
	

	public static void main(String[] args) {
		String str[] ={"jy","JQ","xy","ls","yl","xy"};
		System.out.println(Arrays.toString(deleteJQ(str)));
		System.out.println(Arrays.deepToString(groupStr(str)));
		String[][] st = groupStr(str); 
		System.out.println(Arrays.deepToString(convertStr(st)));
		System.out.println(Arrays.deepToString(deleteRepeat(st)));
    }
	 public static String[] deleteJQ(String[] str){
              for(int i=0;i<str.length;i++){
            	  if(str[i].contains("JQ")){
            		     str[i]=" ";
            	  }      	 
              } return str;
              
 	}
	 public static String [][] groupStr(String[] str){
		     String [][] str1=new String[(str.length+1)/2][2];
		     for(int i=0;i<str1.length;i++){
		    	 str1[i][0]=str[2*i];
		    	 str1[i][1]=str[2*i+1];
		     }return str1;
	 } 
	 
	 public static String[][] convertStr(String[][] st){
		  String [] st1;	
		    for(int i=0;i<st.length;i++){
		    	 String temp=st[i][0];
		    	 st[i][0]=st[i][1];
		    	 st[i][1]=temp;
		    }  for(int i=0;i<st.length/2;i++){
			     st1 =st[i];
			     st[i]=st[st.length-1-i];
			     st[st.length-1-i]=st1;
		  }
		    return st;
	 }
	 
	 public static String[][] deleteRepeat(String[][] st){
		  for(int i=0;i<st.length;i++){
			  for(int p=0;p<2;p++){
				  for(int j=0;j<st.length;j++){
					  for(int k=0;k<2;k++ ){
						  if(!(i==j&&p==k)&&st[i][p]==st[j][k]){
							  st[j][k]=" ";
						  }
					  }
				  }
			  }
		  }return st;
	 }
	 
}
